const productModel = require("../../model/mall/product");
async function searchProduct(req, res) {
    const result = await productModel.searchProduct(req.query.name);
    const json = result;
    res.send(json);
}
async function getCategory(req, res) {
    const data = await productModel.getCategory();
    const json = {
        code: data.code,
        message: data.msg,
        data: data.result,
    };
    res.send(json);
}
async function getAllProduct(req, res) {
    const data = await productModel.getAllProduct();
    const json = {
        code: data.code,
        message: data.msg,
        data: data.result,
    };
    res.send(json);
}
async function getDetail(req, res) {
    const data = await productModel.getDetail(req.query.id);
    const json = {
        code: data.code,
        message: data.msg,
        data: data.result,
    };
    res.send(json);
}
async function getProductByCategory(req, res) {
    const data = await productModel.getProductByCategory(req.query.categoryID);
    const json = {
        code: data.code,
        message: data.msg,
        data: data.result,
    };
    res.send(json);
}
module.exports = {
    getCategory,
    getAllProduct,
    getDetail,
    getProductByCategory,
    searchProduct,
};
